<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    * {
      padding: 0;
      margin: 0;
    }
  </style>
</head>

<body>
  <div id="app">
    <div v-color="msg"></div>
    <input type="text" v-focus>
  </div>
  <script src="../js/vue.js"></script>
  <script>
    /* 
      自定义指令:局部指令
    */
    const vm = new Vue({
      "el": "#app",
      "data": {
        "msg": {
          "color": "orange",
          "width": "300px",
          "height": "200px",
          "border": "1px solid red"
        }
      },
      "methods": {},
      "directives": {
        "focus": { //先起一个名字 
          inserted(el) {
            el.focus();
          }
        },
        "color": {
          bind(el, binding) {
            el.style.width = binding.value.width;
            el.style.height = binding.value.height;
            el.style.backgroundColor = binding.value.color;
            el.style.border = binding.value.border;
          }
        }
      }
    });
  </script>
</body>


</html>